#!/bin/sh
#
# This is the script for generating files for a specific Dalton test job.
#
# For the .check file ksh or bash is preferred, otherwise use sh
# (and hope it is not the old Bourne shell, which will not work)
#
if [ -x /bin/ksh ]; then
   CHECK_SHELL='#!/bin/ksh'
elif [ -x /bin/bash ]; then
   CHECK_SHELL='#!/bin/bash'
else
   CHECK_SHELL='#!/bin/sh'
fi

#######################################################################
#  TEST DESCRIPTION
#######################################################################
cat > dpt_h2s_ff.info <<%EOF%
   dpt_h2s_ff
   -------
   Molecule:       H2S in C2v
   Wave Function:  CCS, CCSD / cc-pVDZ
   Test Purpose:   First-order relativistic corrections w/finite field
%EOF%

#######################################################################
#  INTEGRAL INPUT
#######################################################################
cat > dpt_h2s_ff.mol <<%EOF%
BASIS
cc-pVDZ          
First-order relativistic corrections

    2    2  X  Y      1.00D-15
       16.0   1
S       0.00000000000000    0.00000000000000    0.00000000000000       *
        1.0   1
H       1.82237883747756    0.00000000000000    1.75080674629681       *
%EOF%

#######################################################################
#  DALTON INPUT
#######################################################################
cat > dpt_h2s_ff.dal <<%EOF%
**DALTON
.RUN PROPERTIES
**INTEGRAL
.DIPORG
 0.0 0.0 100.0
.DIPLEN
.THETA
.EFGCAR
.SECMOM
.DARWIN
.MASSVELO
.DPTPOT
.DPTPXP
.KINENER
**WAVE FUNCTION
.CC
*HAMILTONIAN
.FIELD
 0.1
ZDIPLEN
*SCF INP
.THRESH
 1.0D-10
*CC INP
.CCS
.CCSD
.CC(T)
.THRENR
1.0D-10
.THRLEQ
1.0D-07
*CCFOP
.ALLONE
.DPTECO
.2ELDAR
**END OF DALTON INPUT
%EOF%
#######################################################################

 

#######################################################################

#######################################################################
#  CHECK SCRIPT
#######################################################################
echo $CHECK_SHELL >dpt_h2s_ff.check
cat >>dpt_h2s_ff.check <<'%EOF%'
log=$1

if [ `uname` = Linux ]; then
   GREP="egrep -a"
else
   GREP="egrep"
fi

if $GREP -q "not implemented for parallel calculations" $log; then
   echo "TEST ENDED AS EXPECTED"
   exit 0
fi

#First-order DPT energy corrections calculated
#       !  First-order DPT corrections to the ground-state energy  !
#        DPTFLD:     -0.106118498792    (ZDIPLEN )
#        DPTFLD:     -0.106118498792    (TOTAL   )
#        DPTONE:     -2.098268694327
#        DPTREO:      0.727005662770
#        DPTTWO:      0.368308231054
#        Total first-order DPT correction:     -1.109073299295
#       !  First-order DPT corrections to the ground-state energy  !
#        DPTFLD:     -0.106140229575    (ZDIPLEN )
#        DPTFLD:     -0.106140229575    (TOTAL   )
#        DPTONE:     -2.098168077302
#        DPTREO:      0.727075808309
#        DPTTWO:      0.368216480362
#        Total first-order DPT correction:     -1.109016018207
#       !  First-order DPT corrections to the ground-state energy  !
#        DPTFLD:     -0.106141062663    (ZDIPLEN )
#        DPTFLD:     -0.106141062663    (TOTAL   )
#        DPTONE:     -2.098164979985
#        DPTREO:      0.727082299407
#        DPTTWO:      0.368208090099
#        Total first-order DPT correction:     -1.109015653142

CRIT1=`$GREP "Total first-order DPT correction:     \-1\.109073" $log | wc -l`
TEST[1]=`expr   $CRIT1`
CTRL[1]=1
ERROR[1]="CCS first-order DPT correction not correct"

CRIT2=`$GREP "Total first-order DPT correction:     \-1\.1090160" $log | wc -l`
TEST[2]=`expr   $CRIT2`
CTRL[2]=1
ERROR[2]="CCSD first-order DPT correction not correct"

CRIT3=`$GREP "DPTFLD: * (\-0|\-).1061402" $log | wc -l`
TEST[3]=`expr   $CRIT3`
CTRL[3]=2
ERROR[3]="DPT correction to finite field not correct for CCSD"

CRIT4=`$GREP "Total first-order DPT correction:     \-1\.1090156" $log | wc -l`
TEST[4]=`expr   $CRIT4`
CTRL[4]=1
ERROR[4]="CCSD(T) first-order DPT correction not correct"

CRIT5=`$GREP "DPTFLD: * (\-0|\-)\.1061410" $log | wc -l`
TEST[5]=`expr   $CRIT5`
CTRL[5]=2
ERROR[5]="DPT correction to finite field not correct for CCSD(T)"

PASSED=1
for i in 1 2 3 4 5
do
   if [ ${TEST[i]} -ne ${CTRL[i]} ]; then
     echo "${ERROR[i]} ( test = ${TEST[i]}; control = ${CTRL[i]} ); "
     PASSED=0
   fi
done

if [ $PASSED -eq 1 ]
then
  echo TEST ENDED PROPERLY
  exit 0
else
  echo THERE IS A PROBLEM
  exit 1
fi                
%EOF%

chmod +x dpt_h2s_ff.check
#######################################################################
